package cn.boyu.controller;


import cn.boyu.entity.SysDictType;
import cn.boyu.query.DictTypeQuery;
import cn.boyu.result.AjaxResult;
import cn.boyu.service.ISysDictTypeService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yn
 * @since 2022-11-22
 */
@RestController
@RequestMapping("/sysDictType")
@CrossOrigin
public class SysDictTypeController {

    @Autowired
    private ISysDictTypeService dictTypeService;
    //查询
    @GetMapping("/query")
    public AjaxResult query(DictTypeQuery qo){
        Page<SysDictType> page=dictTypeService.queryPage(qo);
        return AjaxResult.success(page);
    }

    //增加  / 修改
    @PostMapping("saveOrUpdate")
    public AjaxResult saveOrUpdate(SysDictType sysDictType){
        dictTypeService.saveOrUpdate(sysDictType);
        return AjaxResult.success();
    }

    //删除
    @PostMapping("/delete")
    public AjaxResult delete(Long id){
        if (id != null) {
            dictTypeService.removeById(id);
            return AjaxResult.success();
        }else{
            return AjaxResult.error();
        }
    }
}

